package com.wxm.killing.mq.common.util;

import com.alibaba.fastjson.JSON;

import java.util.List;

/**
 * Created by zhangchao on 16-2-1.
 *
 */
public class JsonUtil {

    public static <T> String Java2Json(T t){
        return JSON.toJSONString(t);
    }

    public static <T> String JavaList2Json(List<T> tList){
        return JSON.toJSONString(tList);
    }

    public static <T> T Json2Java(String json,Class<T> clazz){
        return JSON.parseObject(json, clazz);
    }

    public static <T> List<T> Json2JavaList(String json,Class<T> clazz){
        return JSON.parseArray(json,clazz);
    }
}

